﻿import QtQuick 2.15
import QtQml

Rectangle{
    id: rectBarBack
    width: parent.width
    height: width/6
    color: "#ffffff"

    property string number: ""
    property string name: ""
    property string curruntIP: ""
    property string curruntPort: ""

    Rectangle{
        id: barBottomLine
        width: parent.width
        height: 1
        color: "#f0f0f0"
        anchors.top: parent.bottom

    }

    Image {
        id: portraitImg
        width: parent.height*0.8
        height: width
        anchors.verticalCenter: parent.verticalCenter
        anchors.left: parent.left
        source: "qrc:/img/defaultPortrait.png"
        anchors.leftMargin: width/2
        fillMode: Image.PreserveAspectFit

    }

    Text {
        id: userName
        text: qsTr("联系人")
        anchors.left: portraitImg.right
        anchors.top: parent.top
        font.bold: true
        font.family: "Arial"
        font.pointSize: 8
        anchors.leftMargin: portraitImg.width/2
        anchors.topMargin: portraitImg.width/4

    }

    Text {
        id: userHistoryRecord
        color: "#a5000000"
        text: qsTr("这是最新消息，聊天记录")
        anchors.left: portraitImg.right
        anchors.top: userName.top
        font.family: "Arial"
        font.pointSize: 8
        anchors.leftMargin: portraitImg.width/2
        anchors.topMargin: portraitImg.width/2

    }

    Text {
        id: userHistoryRecordTime
        color: "#a5000000"
        text: qsTr("17:30")
        anchors.right: parent.right
        anchors.top: parent.top
        font.family: "Arial"
        font.pointSize: 8
        anchors.rightMargin: portraitImg.width/2
        anchors.topMargin: portraitImg.width/2

    }


    Loader {
        id: delLoader
        width: parent.height*0.8
        height: width/2
        z: 11
    }

    MouseArea{
        id: areaBack
        anchors.fill: parent
        hoverEnabled: true

        onClicked: {
            console.log("当前联系人号码：" + number)
            pageStackView.push("ChatPage.qml", {"number": number, "name": name, "curruntIP": curruntIP, "curruntPort": curruntPort})

        }

        onCanceled: {
           parent.color =  "#ffffff"
           cursorShape = Qt.ArrowCursor
        }

        onEntered:
        {
            parent.color =  "#f0f0f0"
            cursorShape = Qt.PointingHandCursor
        }

        onExited: {
            parent.color =  "#ffffff"
            cursorShape = Qt.ArrowCursor
        }

        onPressAndHold: {
            delLoader.x = mouseX
            delLoader.y = mouseY
            delLoader.source = "DelPersonComponent.qml"

        }


    }
}
